var express = require('express');
var router = express.Router();

var Acount = require('../models/acount');
var UserAcount = require('../models/user_acount');

router.get('/remove', function(req, res){

    var flag = false
    Acount.remove({}, function(err, obeject){

        if(!err){
            console.log('Acount remove success');
        }else {
            flag = true;
        }

    });

    UserAcount.remove({}, function(err, obeject){

        if(!err){
            console.log('UserAcount remove success');
        }else {
            flag =true;
        }

    });

    if (!flag) {
        res.render('home',{});
    }else {
        res.json({
            code: -1
        })
    }

})
router.get('/init', function(req, res) {

    var acount1 = new Acount;
    acount1.type_id = 1;
    acount1.acount_name = '306917331@qq.com';
    acount1.password = '306917331';

    acount1.save();

    var acount2 = new Acount;
    acount2.type_id = 2;
    acount2.acount_name = '1_306917331@qq.com';
    acount2.password = '306917331';

    acount2.save();

    var acount3 = new Acount;
    acount3.type_id = 3;
    acount3.acount_name = '2_306917331@qq.com';
    acount3.password = '306917331';

    acount3.save();

    var acount4 = new Acount;
    acount4.type_id = 4;
    acount4.acount_name = '3_306917331@qq.com';
    acount4.password = '306917331';

    acount4.save();

    var acount5 = new Acount;
    acount5.type_id = 1;
    acount5.acount_name = '4_306917331@qq.com';
    acount5.password = '306917331';

    acount5.save();

    var acount6 = new Acount;
    acount6.type_id = 1;
    acount6.acount_name = '5_306917331@qq.com';
    acount6.password = '306917331';

    acount6.save();


    var acount7 = new Acount;
    acount7.type_id = 5;
    acount7.acount_name = '6_306917331@qq.com';
    acount7.password = '306917331';

    acount7.save();

    console.log('v init');

    res.render('home',{});
})

module.exports = router;
